package com.bjpowernode.javase.collection;

import java.util.Objects;

public class Student1 {
    private String name;

    public Student1(){

    }
    public Student1(String name){
        this.name = name;
    }

    public void setName(String name){
        this.name = name;
    }

    public String getName(){
        return name;
    }

    //hashCode

    //equals(如果学生名字一样表示同一个学生)
   /* public boolean equals(Object obj){
        if(obj == null || !(obj instanceof Student1)) return false;
        if(obj == this) return true;
        Student1 student1 = (Student1) obj;
        if (this.name.equals(student1.name)) return true;
        return false;
    }*/

    /*public boolean equals(Object obj){
        if(obj == this) return  true;
        if(obj == null || !(obj instanceof Student1)) return false;
        Student1 s = (Student1)obj;
        return this.name.equals(((Student1) obj).name);
    }
*/

    /*@Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student1 student1 = (Student1) o;
        return Objects.equals(name, student1.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }*/

    public boolean equals(Object obj){
        if(obj == null || !(obj instanceof Student1)) return false;
        if(this == obj) return true;
        Student1 s = (Student1)obj;
        return this.name.equals(s.name);
    }

    /*public int hashCode(){
        return Objects.hash(name);
    }*/

    public int hashCode(){
        return Objects.hash(name);
    }
}
